package com.xiaoshuidi.cloud.module.rooms.enums;

import cn.hutool.core.lang.Assert;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author hans.zhang
 */
@Getter
@AllArgsConstructor
public enum RoomTypeEnum {
    ZW("主卧","1"),
    CW("次卧","2"),
    KW("客卧","3"),
    GGQY("公共区域","4"),
    ;

    private String name;
    private String value;

    public static String getValueByName(String name) {
        RoomTypeEnum roomTypeEnum = Arrays.stream(RoomTypeEnum.values()).filter(p -> p.name.equals(name)).findFirst().orElse(null);
        Assert.isTrue(roomTypeEnum != null,"RoomTypeEnum类型:{}不存在",name);
        return roomTypeEnum.getValue();
    }

    public static String getNameByValue(String value) {
        RoomTypeEnum roomTypeEnum = Arrays.stream(RoomTypeEnum.values()).filter(p -> p.value.equals(value)).findFirst().orElse(null);
        Assert.isTrue(roomTypeEnum != null,"RoomTypeEnum类型:{}不存在",value);
        return roomTypeEnum.getName();
    }

}
